import request from './request';

// 时政模块API
export function getPoliticsQuestions(params: any) {
  return request({
    url: '/api/politics/questions',
    method: 'get',
    params,
  });
}

// 通用接口名称，供QuestionBankManager组件使用
export function getQuestions(params: any) {
  return getPoliticsQuestions(params);
}

// 添加时政模块问题
export function addPoliticsQuestion(data: any) {
  return request({
    url: '/api/politics/questions',
    method: 'post',
    data,
  });
}

// 通用接口名称
export function addQuestion(data: any) {
  return addPoliticsQuestion(data);
}

export function updatePoliticsQuestion(id: string, data: any) {
  return request({
    url: `/api/politics/questions/${id}`,
    method: 'put',
    data,
  });
}

// 通用接口名称
export function updateQuestion(id: string, data: any) {
  return updatePoliticsQuestion(id, data);
}

export function deletePoliticsQuestion(id: string) {
  return request({
    url: `/api/politics/questions/${id}`,
    method: 'delete',
  });
}

// 批量删除时政题目
export function batchDeletePoliticsQuestions(ids: string[]) {
  return request({
    url: '/api/politics/questions/batch',
    method: 'delete',
    data: ids
  });
}

// 通用接口名称
export function deleteQuestion(id: string) {
  return deletePoliticsQuestion(id);
}

// 通用批量删除接口名称
export function batchDeleteQuestions(ids: string[]) {
  return batchDeletePoliticsQuestions(ids);
}

// 提交答案
export function submitAnswer(data: any) {
  return request({
    url: '/api/politics/submit-answer',
    method: 'post',
    data,
  });
}

// 获取单个时政题目
export function getPoliticsQuestion(id: string) {
  return request({
    url: `/api/politics/questions/${id}`,
    method: 'get',
  });
}

// 通用接口名称
export function getQuestion(id: string) {
  return getPoliticsQuestion(id);
}

// 获取练习题目
export function getPracticeQuestions(params: any) {
  return request({
    url: '/api/politics/practice',
    method: 'get',
    params,
  });
}

// 通用练习接口名称
export function getPractice(params: any) {
  return getPracticeQuestions(params);
}